<template>
  <div class="sign-exception">
    <div class="query-container">
      <div style="padding-left: 40px; margin-bottom: 20px;">
        <el-menu
          :default-active="activeIndex"
          class="el-menu-demo"
          style="width: 226px"
          mode="horizontal"
          @select="handleSelect"
          text-color="var(--prev-color-text-regular)"
          active-text-color="var(--prev-color-primary)">
          <el-menu-item index="1">送货异常</el-menu-item>
          <el-menu-item index="2">签收异常</el-menu-item>
        </el-menu>
      </div>
      <el-form inline label-width="90px">
        <div style="width:78%;float: left">
          <el-form-item label="发货时间" :required="true">
            <el-date-picker
              v-model="fromTime"
              style="width: 226px"
              type="daterange"
              range-separator="至"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
              value-format="yyyy-MM-dd"
              clearable
              @change="fromTimeGive">
            </el-date-picker>
          </el-form-item>
          <el-form-item label="合同编号" v-if="activeIndex == 1">
            <el-input v-model="params.contractNo" placeholder="请输入合同编号" style="width: 226px"></el-input>
          </el-form-item>
          <el-form-item label="提货地" v-if="activeIndex == 1">
            <el-input v-model="params.fromShortName" placeholder="请输入提货地" style="width: 226px"></el-input>
          </el-form-item>
          <el-form-item label="收货地" v-if="activeIndex == 1">
            <el-input v-model="params.consigneeName" placeholder="请输入收货地" style="width: 226px"></el-input>
          </el-form-item>
          <el-form-item label="异常" v-if="activeIndex == 1">
            <el-select v-model="params.exceptionFlag" placeholder="请选择" style="width: 226px" clearable>
              <el-option
                v-for="(item,index) in exceptionFlag"
                :key="index"
                :label="item.name"
                :value="item.value">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="CDC仓库" v-if="activeIndex == 1">
            <el-select v-model="params.topWarehouseShortName" placeholder="请选择" style="width: 226px" clearable>
              <el-option
                v-for="(item,index) in options.CDCwarehouse"
                :key="index"
                :label="item.name"
                :value="item.value">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="OEM供应商" v-if="activeIndex == 1">
            <el-select v-model="oemGysCode" filterable placeholder="请选择" style="width: 226px" @change="controlTypeChange" clearable>
              <el-option
                v-for="(item,index) in options.OEMOptions"
                :key="index"
                :label="item.name"
                :value="item.oemGysCode">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="承运方">
            <el-select v-model="params.supplierCompanyId" filterable placeholder="请选择" style="width: 226px" clearable>
              <el-option
                v-for="(item,index) in carrierOptions"
                :key="index"
                :label="item.name"
                :value="item.supplierCompanyId">
              </el-option>
            </el-select>
          </el-form-item>
        </div>
        <el-form-item style="width:262px;float: right">
          <el-button type="primary"
                     icon="el-icon-search"
                     @click="search(1)">查询</el-button>
          <el-button type="primary"
                     icon="el-icon-delete"
                     @click="resetForm">清除</el-button>
          <el-button type="default"
                     icon="el-icon-s-promotion"
                     @click="handleExport">导出</el-button>
        </el-form-item>
      </el-form>
    </div>
    <div class="bottom-container">
      <el-table class="table-container"
                stripe
                border
                :data="tableData"
                v-loading="loading"
                element-loading-text="加载中"
                element-loading-spinner="el-icon-loading"
                show-summary
                :summary-method="getSummaries"
                @sort-change="sortChange">
          <el-table-column
          v-for="(column, index) in columns"
            :key="index"
            :prop="column.prop"
            :label="column.name"
            :sortable="column.sortable?'custom':false"
            :align="column.align?column.align:'right'"
            :width="column.width?column.width:''"
          >
            <template slot-scope="scope">
              <el-tooltip v-if="column.prop == 'oEMExceptionNum' 
                          || column.prop == 'gXZFExceptionNum' || column.prop == 'jXSExceptionNum'" 
                        class="item" effect="dark" 
                        :content="'异常运单数'+ scope.row[column.prop]+ '/异常箱数' +scope.row[column.props]" 
                        placement="top-start">
                      <span >{{scope.row[column.prop]+ '/' +scope.row[column.props]}}</span>
              </el-tooltip>
              <span v-else-if="column.name == '异常数' || column.name == '异常运单数'" 
                :style="scope.row[column.prop]?'color: #cd0000;':''">
                {{transition((scope.row[column.prop]),column.props,scope)}}</span>
              <span v-else>{{transition((scope.row[column.prop]),column.props,scope)}}</span>
            </template>
          </el-table-column>
      </el-table>
      <span v-show="tableData.length > 0" style="color: #eb662b;">说明:由于四舍五入的原因，本页合计和总合计可能存在误差。</span>
      <el-pagination v-show="tableData.length > 0"
                     background
                     layout="total, sizes, prev, pager, next, jumper"
                     :total="total"
                     :page-sizes="pageSizeOptions"
                     :page-size.sync="pageSize"
                     :current-page.sync="pageNo"
                     @size-change="handleSizeChange"
                     @current-change="handleCurrentChange">
      </el-pagination>
    </div>
  </div>
</template>

<script src="./rmsJs/SignException.js"></script>

<style scoped>
.table-container >>> .el-table__body-wrapper {
  height: calc(100% - 168px);
  overflow-y: auto;
}
.bottom-container >>> .el-pagination {
  margin-top: 20px;
  /* text-align: right; */
}
.bottom-container >>> .el-table tr {
  background-color: var(--prev-bg-white);
  height: 50px;
  font-size: 14px;
}
.sign-exception >>> .el-table th.el-table__cell.is-leaf,
.el-table td.el-table__cell {
  border-bottom: 1px solid var(--prev-border-color-lighter);
  font-size: 14px;
  font-family: PingFang SC;
  font-weight: 400;
  line-height: 20px;
  color: #333333;
  opacity: 1;
}
</style>
<style lang="scss" scoped>
.sign-exception {
  width: 100%;
  height: 100%;
  .query-container {
    padding: 20px 20px 0px 0;
    background: var(--prev-bg-white);
    overflow: hidden;
  }
  .bottom-container {
    padding: 20px;
    margin-top: 12px;
    background: var(--prev-bg-white);
    height: calc(100vh - 270px);
    .table-container {
      height: calc(100% - 140px);
      .target-power {
        display: flex;
        .power {
          display: flex;
          align-items: center;
        }
      }
    }
  }
}
</style>
